package com.lsh.factory;

import com.lsh.factory.store.ICommodity;
import com.lsh.factory.store.impl.CardCommodityService;
import com.lsh.factory.store.impl.CouponCommodityService;
import com.lsh.factory.store.impl.GoodsCommodityService;

/**
 * @author ：LiuShihao
 * @date ：Created in 2021/12/2 5:29 下午
 * @desc ：商店 工厂
 */
public class StoreFactory {
    /**
     * 获得商品服务（优惠券、实体商品、会员卡）
     * @param commodityType
     * @return
     */
    public ICommodity getCommodityService(Integer commodityType) {
        if (null == commodityType) return null;
        if (1 == commodityType) return new CouponCommodityService();
        if (2 == commodityType) return new GoodsCommodityService();
        if (3 == commodityType) return new CardCommodityService();
        throw new RuntimeException("不存在的商品服务类型");
    }
}
